﻿namespace regressiveanalysis

{

    internal class Program
    {
        static void Main(string[] args)
        {
            long[,] GDP = new long[30, 2];
            for (int i = 0; i < 30; i++)
            {
                GDP[i, 0] = i + 1991;
            }
            GDP[0, 1] = 383373312000;
            GDP[1, 1] = 426915725312;
            GDP[2, 1] = 444731293696;
            GDP[3, 1] = 564324663296;
            GDP[4, 1] = 734547898224;
            GDP[5, 1] = 863746717507;
            GDP[6, 1] = 961603952954;
            GDP[7, 1] = 1029043097558;
            GDP[8, 1] = 1093997267277;
            GDP[9, 1] = 1211346869600;
            GDP[10,1] = 1339395718862;
            GDP[11, 1] = 1470550015077;
            GDP[12, 1] = 1660287965663;
            GDP[13, 1] = 1955347004865;
            GDP[14, 1] = 2285965892364;
            GDP[15, 1] = 2752131773358;
            GDP[16, 1] = 3550342737009;
            GDP[17, 1] = 4594307032667;
            GDP[18, 1] = 5101703073088;
            GDP[19, 1] = 6087163874510;
            GDP[20, 1] = 7551500124197;
            GDP[21, 1] = 8532229986993;
            GDP[22, 1] = 9570406235659;
            GDP[23, 1] = 10475682920597;
            GDP[24, 1] = 11061553079871;
            GDP[25, 1] = 11233276536744;
            GDP[26, 1] = 12310409370894;
            GDP[27, 1] = 13894817549380;
            GDP[28, 1] = 14279937500608;
            GDP[29, 1] = 14687673892882;
            double a, b,average_x=0.0,average_y=0.0,total_x=0.0,total_y=0.0,numerator=0.0,denominator=0.0,x,y,year;
            for(int i=0;i<=29; i++)
            {
                total_x +=GDP[i, 0];
                total_y +=GDP[i, 1];
            }
            average_x = total_x / 30;
            average_y = total_y / 30;
            for(int i=0;i<=29;i++)
            {
                numerator += (GDP[i, 0] - average_x) * (GDP[i, 1] - average_y);
                denominator += (GDP[i, 0] - average_x) * (GDP[i, 0] - average_x);
            }
            b = numerator / denominator;
            a = average_y - (b * average_x);
            Console.WriteLine("请输入要查询的年份");
            year = Console.Read();
            y = a + (b * Math.Pow(1.1645243,year));
            Console.WriteLine(y);
         }
    }
}